package com.dykj.fireFighting.web.controller;
import com.dykj.fireFighting.api.elasticsearch.devHisZc.entity.EsDevHisZc;
import com.dykj.fireFighting.api.elasticsearch.devHisZc.service.EsDevHisZcService;
import com.dykj.fireFighting.api.monitoringCenter.dto.DevHisElectricalDto;
import com.dykj.fireFighting.api.monitoringCenter.dto.DevHisZcDto;
import com.dykj.fireFighting.api.monitoringCenter.entity.DevHisElectrical;
import com.dykj.fireFighting.api.monitoringCenter.service.IDevHisElectricalService;
import com.dykj.fireFighting.common.core.annotation.AutoLog;
import com.dykj.fireFighting.common.core.api.CommonResult;
import com.dykj.fireFighting.common.core.vo.PageVo;
import com.dykj.fireFighting.web.base.shiro.ShiroUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 电气火灾报警设备运行记录接口
 *
 * @Author fgc
 * @Date  2021-06-21 10:58:04
 */
@Slf4j
@Api(value = "电气火灾报警设备运行记录接口", tags = {"电气火灾报警设备运行记录接口"})
@RestController
@RequestMapping("devHisElectrical")
public class DevHisElectricalController {
   @DubboReference
    private IDevHisElectricalService devHisElectricalService;
    @DubboReference
    private EsDevHisZcService esDevHisZcService;

    /**
     * 电气火灾报警设备运行记录列表
     *
     * @return
     */
//    @AutoLog(value = "电气火灾报警设备运行记录-分页列表查询")
//    @ApiOperation(value = "电气火灾报警设备运行记录分页列表", notes = "电气火灾报警设备运行记录分页列表")
//    @GetMapping("/list")
//    @RequiresPermissions("devHisElectrical/list")
//    public CommonResult<PageVo<DevHisElectrical>> treeGrid(DevHisElectricalDto devHisElectricalDto) {
//        Long enterpriseId = ShiroUtil.getUser().getEnterpriseId();
//        if(StringUtils.isBlank(devHisElectricalDto.getSocialUnitId())){
//            devHisElectricalDto.setUserUnitId(enterpriseId+"");
//        }
//        PageVo<DevHisElectrical> page = devHisElectricalService.pageList(devHisElectricalDto);
//        return CommonResult.success(page);
//    }

    @GetMapping("/list")
    public CommonResult<PageVo<EsDevHisZc>> getPage(DevHisZcDto devHisZcDto){
        Long enterpriseId = ShiroUtil.getUser().getEnterpriseId();
        PageVo<EsDevHisZc> pageVo = esDevHisZcService.searchByCenterId(enterpriseId.toString(), devHisZcDto.getSocialUnitId(), devHisZcDto.getName(),
                (int) devHisZcDto.getPage(), (int) devHisZcDto.getLimit(),devHisZcDto.getBeginDate(),devHisZcDto.getEndDate());
        return CommonResult.success(pageVo);
    }


}
